<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function maopao(arr){
            for(i = 0; i < arr.length - 1 ; i++){
                for(j = 0; j < arr.length - 1 - i; j++){
                    if(arr[j] > arr[j + 1]){
                        var tem = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = tem;
                    }
                }
            }
            return arr;
        }
        var tem2 = maopao([1, 5, 8, 77, 2]);
        console.log(tem2);
        
    </script>
</body>
</html>